Basic DOM Manipulation


Exercise 1

Change the background color of the entire webpage when a button is clicked.

   
    function changeBG(){
        const ex1 = document.getElementsByClassName('bodyclass');
        ex1[0].style.backgroundColor = "red";
    }
    

Exercise 2

Create a list of items. When a user clicks on an item, change its font style (e.g., bold, italic).

   
  
    
  • APPLE
  • BANANA
  • WaterMelon

Exercise 3

Create a form with a name input field. When the form is submitted, display the entered name in a separate paragraph element.

   


Output will Print Here